﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using LEET.StaticAnalisys;

namespace StaticAnalisys.Reports
{
    public class CompositeReport : IReport
    {
        protected IList<IReport> reports;

        public CompositeReport()
        {
            reports = new List<IReport>();
        }

        public void Add(IReport visitor)
        {
            reports.Add(visitor);
        }
        
        public IEnumerable<IReporting> Errors()
        {
            List<IReporting> errors = new List<IReporting>();
            foreach (IReport r in reports)
                errors.AddRange(r.Errors());
            return errors;
        }

        public IEnumerable<IReporting> Warnings()
        {
            List<IReporting> warnings = new List<IReporting>();
            foreach (IReport r in reports)
                warnings.AddRange(r.Warnings());
            return warnings;
        }

        public void Visit(INode node)
        {
            foreach (IVisitor visitor in reports)
                visitor.Visit(node);
        }
    }
}
